"""
while 条件：
    条件满足时，做的事情1
    条件满足时，做的事情2
    。。。省略。。。
"""
i = 0
while i < 5:          # 设定当达到何条件时，停止循环
    print('我爱你')
    i = i + 1           # 充当计时器
"""
通过while循环，计算从1累加到100的和
"""
a = 1
c = 0
while a < 101:
    c = c + a
    a = a + 1
print(c)

"""
通过while循环，完成猜数字游戏，完成：
无限次机会，直到猜中为止
每一次猜不中，会提示大了或者小了
猜数字后，提示猜了几次
"""
import random
num = random.randint(1,100)
num_guess = 0
while num == num_guess:
    num_guess = input('please input the number you guess')
    num_guess = int(num_guess)
    if num == num_guess:
        print('yeah, you guessed the right number')
    else:
        print('you did not guess the right number')
        if num < num_guess:
            print('the number you guess < the right number')
        else:
            print('the number you guess > the right number')

# 5的阶乘
n = 0
m= 1
while n < 5:
    m = m * (n + 1)
    n = n + 1
print(m)



